package com.veo.service.Imp;

import com.github.pagehelper.PageHelper;
import com.veo.dao.ProductDao;
import com.veo.domain.Product;
import com.veo.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;

@Service("productService")
@Transactional
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductDao productDao;


    public List<Product> findAllProduct(int page, int size, String searcherName) {
        //实现分页
        PageHelper.startPage(page,size);
        return productDao.findAllProduct(searcherName);
    }

    public int addProduct(Product product) {
        return productDao.addProduct(product);
    }

    public Product findProductById(String id) {
        return productDao.findProductById(id);
    }

    public int updateProduct(Product product) {
        return productDao.updateProduct(product);
    }

    public int deleteProductById(String id) {
        return productDao.deleteProductById(id);
    }

    public int updateProductStatus(String id,Integer status) {
        return productDao.updateProductStatus(id,status);
    }
}
